const http = require("http");
const fs = require("fs");

http.createServer((req, res) => {
    var urlObj = new URL(req.url, "http://localhost:8081/");
    var pathName = urlObj.pathname;
    if(pathName == "/"){
        var fileContent = fs.readFileSync("./post.html");
        res.writeHead(200, {"Content-Type": "text/html;charset:utf8"});
        res.write(fileContent);
        res.end();
    }else if(pathName == "/list"){
        var fileContent = fs.readFileSync("./list.html");
        res.writeHead(200, {"Content-Type": "text/html;charset:utf8"});
        res.write(fileContent);
        res.end();
    }
}).listen(8081)